@echo off
echo "==>TAO_ROOT=%TAO_ROOT%"

set PROJECT_PATH="%TAO_ROOT%/orbsvcs/DevGuideExamples/EventServices/RTEC_Filter"
cd %PROJECT_PATH%


@echo off
setlocal

:: 定义要删除的文件列表
set "files=ns.ior es.ior"

:: 遍历文件列表并删除存在的文件
for %%f in (%files%) do (
    if exist "%%f" (
        echo Deleting %%f...
        del "%%f"
        if not errorlevel 1 (
            echo Deleted %%f successfully.
        ) else (
            echo Error deleting %%f.
        )
    ) else (
        echo %%f does not exist. Skipping.
    )
)

:: 推模式 EchoEventSupplier ------> Event_Service ------> EchoEventConsumer

::1) Start tao_ft_naming
echo "==>Start Naming_Service
start "tao_cosnaming" cmd /k "%TAO_ROOT%/orbsvcs/Naming_Service/tao_cosnaming -ORBdebuglevel 0  -o %PROJECT_PATH%/ns.ior"
timeout /t 3


::2) Start tao_cosevent 实时事件服务仅支持推模型的操作。
echo "==>Start tao_cosevent
start "tao_cosevent" cmd /k "%TAO_ROOT%/orbsvcs/Event_Service/tao_rtevent -ORBdebuglevel 0 -o %PROJECT_PATH%/es.ior -ORBInitRef NameService=file://%PROJECT_PATH%/ns.ior"
timeout /t 3

::4) Start test object EchoEventSupplier
echo "==>Start EchoEventSupplier
start "EchoEventSupplier" cmd /k "EchoEventSupplier -ORBInitRef NameService=file://%PROJECT_PATH%/ns.ior"

::5) Start test object EchoEventConsumer
echo "==>Start EchoEventConsumer
start "EchoEventConsumer" cmd /k "EchoEventConsumer -ORBInitRef NameService=file://%PROJECT_PATH%/ns.ior"

pause >nul
@echo off